package com.quickly.develop.common.entity;

import java.io.Serializable;
import java.util.List;

import com.quickly.develop.common.base.BaseEntity;
import com.quickly.develop.common.constant.ConEntity;

/**
 * @Description: 分页查询返回
 * @Author:
 * @Date: 2019/10/11 13:08
 */
public class PageResponse<T extends BaseEntity> implements Serializable {

	private static final long serialVersionUID = 620421858510718076L;

	/**
	 * 返回code值 根据layui table 异步数据需要默认0
	 */
	private int code = ConEntity.CODE_SUCCESS;
	private String msg = "";
	/**
	 * 数据总条数
	 */
	private Integer count;
	private List<T> data;

	public PageResponse() {
		super();
	}

	public PageResponse(Integer count, List<T> data) {
		super();
		this.count = count;
		this.data = data;
	}

	public PageResponse<T> SUCCESS() {
		PageResponse<T> response = new PageResponse<T>();
		response.setCode(ConEntity.CODE_SUCCESS);
		response.setMsg(ConEntity.MSG_SUCCESS);
		return response;
	}

	public PageResponse<T> SUCCESS(String msg) {
		PageResponse<T> response = new PageResponse<T>();
		response.setCode(ConEntity.CODE_SUCCESS);
		response.setMsg(msg);
		return response;
	}

	public PageResponse<T> FAILE() {
		PageResponse<T> response = new PageResponse<T>();
		response.setCode(ConEntity.CODE_FAILE);
		response.setMsg(ConEntity.MSG_FAILE);
		return response;
	}

	public PageResponse<T> FAILE(String msg) {
		PageResponse<T> response = new PageResponse<T>();
		response.setCode(ConEntity.CODE_FAILE);
		response.setMsg(msg);
		return response;
	}

	public List<T> getData() {
		return data;
	}

	public void setData(List<T> data) {
		this.data = data;
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public Integer getCount() {
		return count;
	}

	public void setCount(Integer count) {
		this.count = count;
	}
}
